import java.io.*;
import java.util.zip.*;

public class Zip implements Zipleme {
   static final int BUFFER = 2048;
   private String zipYolu = null;
   
   public Zip(String dosyaYolu){
	   this.zipYolu = dosyaYolu+File.separatorChar+".tist"+File.separatorChar+"ornek.zip";
   }
   
   public String ziple(){
	   try {
	         BufferedInputStream origin = null;
	         FileOutputStream dest = new 
	           FileOutputStream(zipYolu);
	         ZipOutputStream out = new ZipOutputStream(new 
	           BufferedOutputStream(dest));
	         //out.setMethod(ZipOutputStream.DEFLATED);
	         byte data[] = new byte[BUFFER];
	         // get a list of files from current directory
	         File f = new File(".");
	         String files[] = f.list();

	         for (int i=0; i<files.length; i++) {
	        	File tempr = new File(files[i]);
	        	if (!tempr.isDirectory() && files[i].endsWith(".txt")){
	            System.out.println("Adding: "+files[i]);
	            FileInputStream fi = new  FileInputStream(files[i]);
	            origin = new 
	              BufferedInputStream(fi, BUFFER);
	            ZipEntry entry = new ZipEntry(files[i]);
	            out.putNextEntry(entry);
	            int count;
	            while((count = origin.read(data, 0, 
	              BUFFER)) != -1) {
	               out.write(data, 0, count);
	            }
	            origin.close();
	        	}
	         }
	         out.close();
	      } catch(Exception e) {
	         e.printStackTrace();
	      }
	      
	      return zipYolu;

   }
	      
}
